{% extends "main/base.html" %}
{% load i18n static main_tag %}
{% block title %}{% trans '设备采购列表' %}{% endblock %}
{% block this_css %}
<link rel="stylesheet" type="text/css" href="{% static 'flatlab/css/bootstrap-select.min.css' %}">
{% endblock %}
{% block content %}
<section class="panel">
    <div class="panel-body">
        <div class="col-md-9">
            <form class="form-inline" role="form" method="get">
                <div class="form-group">
                    <select name="c" class="selectpicker show-tick form-control" data-live-search="true">
                        <option value="">{% trans '所有设备' %}</option>
                        {% for ss in equipment_types %}
                            {% if ss.pk|floatformat:'0' == request.GET.c|floatformat:'0' %}
                            <option value="{{ ss.pk }}" selected>{{ ss }}</option>
                            {% else %}
                            <option value="{{ ss.pk }}" >{{ ss }}</option>
                            {% endif %}
                        {% endfor %}
                    </select>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <input class="form-control" type="text" name="q" value="{% if request.GET.q %}{{ request.GET.q }}{% endif %}">
                        <span class="input-group-btn"><button class="btn btn-primary" type="submit">搜索</button></span>
                    </div>
                </div>
            </form>
        </div>
        <div class="col-md-3" align="right">{% if perms.main.add_equipmentassembly %}
            <a href="{% url 'main:plan_assembly_create' %}?next={{ request.path }}"><button type="button" class="btn btn-success">{% trans "新建采购" %}</button></a>{% endif %}
        </div>
    </div>
</section>
<section class="panel">
    {% get_current_language as LANGUAGE_CODE %}
    <div class="table-responsive panel-body">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>{% trans '设备组装名称' %}</th>
                    <th>{% trans '数量' %}</th>
                    <th>{% trans '备注' %}</th>
                    <th>{% trans '已经采购' %}</th>{% if perms.main.change_equipmentassembly %}
                    <th></th>{% endif %}
                </tr>
            </thead>
            <tbody>
            {% for d in page_obj %}
                <tr>
                    <td>{{ d.pk }}</td>
                    <td>{{ d.related_equipment_assembly }}</td>
                    <td>{{ d.amount }}</td>
                    <td>{{ d.notes|linebreaks }}</td>
                    <td>{{ d.is_ordered }}</td>
                    <td align="right">
                        <a href="{% url 'main:plan_assembly_detail' d.pk %}"><button class="btn btn-warning btn-xs"><i class="fa fa-home"></i></button></a>
                        <a href="{% url 'main:plan_assembly_update' d.pk %}?next={% url 'main:plan_assembly_list' %}"><button class="btn btn-success btn-xs"><i class="fa fa-pencil"></i></button></a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        <div align="right">
            {% include 'main/tablenav.html' %}
        </div>
    </div>
</section>
{% endblock %}
{% block this_js %}
<script type="text/javascript" src="{% static 'flatlab/js/bootstrap-select.min.js' %}"></script>
{% endblock %}